<tal:block metal:define-macro="standard">
  <tal:block metal:use-macro="structure/metatags.xhtml/editor" />
  
  <table>
    <tr style="background-color:#e3e3e3; font-weight: bold;">
      <td colspan="4">
        <span tal:condition="not:detail | NULL">${text/ticket_titel_header_neu | NULL}</span>
        <span tal:condition="detail | NULL">${text/ticket_titel_header_edit | NULL}</span>
        <div style="float:right;">
          <button type="submit" aria-label="Left Align" title="${text/ticket_save_button | NULL}" class="btn btn-default glyphicon glyphicon-ok" aria-hidden="true" />
          <a type="button" aria-label="Left Align" title="${text/system_cancel | NULL}" class="btn btn-default glyphicon glyphicon-remove" aria-hidden="true" href="javascript:history.back();" />
        </div>
      </td>
    </tr>

    <tr>
      <td style="width:20%;">${text/ticket_titel | NULL}</td>
      <td style="width:30%;">
        <input tal:condition="not:detail | NULL" type="text" name="titel" id="contactEmail" class="form-control" />
        <input tal:condition="detail | NULL" type="text" name="titel" id="contactEmail" class="form-control" value="${detail/ticket/0/titel | NULL}" />
      </td>
      <td style="width:20%;">${text/ticket_status | NULL}</td>
      <td style="width:30%;">
        <select class="form-control" name="ticket_status" size="1">
          <option tal:condition="not:detail | NULL" tal:repeat="status ticket_status" value="${status/key}">${status/val}</option>
          <option tal:condition="detail | NULL" tal:repeat="status ticket_status" value="${status/key}" tal:attributes="selected php: status['val'] == detail['ticket']['0']['ticket_status']">${status/val}</option>          
        </select>
      </td>
    </tr>
    
    <tr>
      <td>${text/ticket_prio | NULL}</td>
      <td>
        <select class="form-control" name="prio" size="1">
          <option tal:condition="not:detail | NULL" tal:repeat="prio ticket_prio" value="${prio/key}">${prio/val}</option>
          <option tal:condition="detail | NULL" tal:repeat="prio ticket_prio" value="${prio/key}" tal:attributes="selected php: prio['val'] == detail['ticket']['0']['prio']">${prio/val}</option>
        </select>
      </td>
      <td>${text/ticket_fortschritt | NULL}</td>
      <td>
        <select class="form-control" name="fortschritt" size="1">
          <option tal:condition="detail | NULL" tal:repeat="fortschritt erledigt" value="${fortschritt}" tal:attributes="selected php: fortschritt == detail['ticket']['0']['fortschritt']">${fortschritt}%</option>
          <option tal:condition="not:detail | NULL" tal:repeat="fortschritt erledigt" value="${fortschritt}">${fortschritt}%</option>
        </select>
      </td>
    </tr>
       
    <tr style="background-color:#e3e3e3; font-weight: bold;">
      <td colspan="4">${text/ticket_titel_header_2 | NULL}</td>
    </tr>

    <tr>
      <td>${text/ticket_abgabe_datum | NULL}</td>
      <td>
        <input tal:condition="not:detail | NULL" type="text" name="abgabetermin" id="contactEmail" class="tcal form-control" />
        <input tal:condition="detail | NULL" type="text" name="abgabetermin" id="contactEmail" class="tcal form-control" value="${detail/ticket/0/abgabetermin | NULL}" />
      </td>
      <td>${text/ticket_zuordnung | NULL}</td>
      <td>
        <select class="form-control" name="zuordnung" size="1">
          <option tal:condition="not:detail | NULL" tal:repeat="user user_liste" value="${user/username | NULL}">${user/displayName}</option>
          <option tal:condition="detail | NULL" tal:repeat="user user_liste" value="${user/username | NULL}" tal:attributes="selected php: user['displayName'] == detail['ticket']['0']['zuordnung']">${user/displayName}</option>
        </select>
      </td>
    </tr>        
  
    <tr style="background-color:#e3e3e3; font-weight: bold;">
      <td colspan="4">${text/ticket_titel_header_3 | NULL}</td>
    </tr>

    <tr>
      <td>${text/ticket_system | NULL}</td>
      <td colspan="3">
        <select class="form-control" name="smt_system" size="1">
          <option>Server oder virtuelle Maschine wählen</option>
          <option>------------------------------------------------------------------------------------</option>
          <option tal:condition="not:detail | NULL" tal:repeat="server server_liste" value="${server/id}">${server/bezeichnung}</option>
          <option tal:condition="detail | NULL" tal:repeat="server server_liste" value="${server/id}" tal:attributes="selected php: server['id'] == detail['ticket']['0']['smt_system']['id']">${server/bezeichnung}</option>
        </select>
      </td>
    </tr>

    <tr>
      <td colspan="4"><textarea name="beschreibung" class="form-control" id="contactComment" style="width:100%;height:200px;">${ticket_detail/beschreibung | NULL}</textarea></td>
    </tr>
    
    <tr style="background-color:#e3e3e3; font-weight: bold;">
      <td colspan="4">${text/ticket_titel_header_4 | NULL}</td>
    </tr>
    
    <tr>
      <td VALIGN="TOP">${text/ticket_beobachter| NULL}</td>
      <td>
        <select class="form-control" name="beobachter[]" size="5" multiple="">
          <option tal:condition="not:detail | NULL" tal:repeat="user user_liste" value="${user/username | NULL}">${user/displayName}</option>
          <option tal:condition="detail | NULL" tal:repeat="user user_liste" value="${user/username | NULL}" tal:attributes="selected php: in_array(user['displayName'], detail['ticket']['0']['beobachter'])">${user/displayName}</option>
        </select>
      </td>
      <td VALIGN="TOP">${text/ticket_anhang | NULL}</td>
      <td VALIGN="TOP">
        <input type="file" name="filesToUpload[]" id="filesToUpload" multiple="multiple" onChange="makeFileList();" /><br /><ul id="fileList"></ul>
      </td>
    </tr>
    
  </table>

</tal:block>